<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		
		<script>
			
			// 1. while
			var i = 0;
			while(i < 5){
				document.write("<h3>hello,world!</h3>");
				i++;
			}
			
			// 2. do-while
			var j = 0;
			do{
				document.write("<h3 style='color:red>JavaScript</h3>")
				j++;
			}while(j < 5)
			
			// 3. for语句
			for(var k = 0; k < 5; k++){
				document.write("<h3 style='color:green'>FOR循环</h3>");
			}
			
		</script>
		
		<h1>乘法口诀表</h1>
		<script>
			for(var a = 1; a <= 9; a++){
				for(var b = 1;b <=a; b++){
					document.write(a+"*"+b+"="+a*b+"&nbsp;&nbsp;&nbsp;");
				}
				document.write("<br/>");
			}
			
		</script>
		
		<h1>循环加法</h1>
		请输入一个数字n：
		<input type="text" id="input1">
		<button onclick="adder()">结果</button>
		<script>
			
			function adder(){
				var total = 0;
				for(var a = 1; a <= input1.value; a++){
					total += a;
				}
				alert("1+2+...+n="+total);
			}

		</script>
		
	</body>
</html>
